package com.teamwhole.modules.sys.service;

import java.util.Date;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;

import com.teamwhole.common.utils.IdGen;
import com.teamwhole.core.persistence.service.CrudService;
import com.teamwhole.modules.sys.dao.AttachmentInfoDao;
import com.teamwhole.modules.sys.entity.AttachmentInfo;

@Service
public class AttachmentInfoService extends CrudService<AttachmentInfoDao, AttachmentInfo> {
	
	@Autowired
	private AttachmentService as;
	
	@Transactional(readOnly = false)
    public void save(AttachmentInfo entity) {
		// 保存主体信息
		entity.getAttachment().setCreateTime(new Date());
		as.save(entity.getAttachment());
		
		// TODO ID 规则
		entity.setId(IdGen.uuid());
		entity.setFileId(entity.getAttachment().getId());
		dao.insert(entity);
    }
	

}
